package Demo04;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 28463
 * Date: 2022—05—16
 * Time: 19:53
 */

abstract class Animal {
    public String name;
    public int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }
    public abstract void eat() ;
}
interface IRunning {
    public void run() ;
}
interface IFlying {
    public void fly();
}
class Dog extends Animal implements IRunning{
    public Dog(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(name + "正在吃狗粮！ ");
    }
    @Override
    public void run(){
        System.out.println(name+" 正在跑 ");
    }
}

class Bird extends Animal implements IRunning,IFlying{

    public Bird(String name, int age) {
        super(name, age);
    }

    @Override
    public void eat() {
        System.out.println(name + "正在吃鸟粮！ ");
    }
    @Override
    public void run(){
        System.out.println(name+" 正在慢跑走 ");
    }
    @Override
    public void fly(){
        System.out.println(name+" 正在用翅膀飞 ");
    }
}
public class Test05 {

    public static void func1(Animal animal){
        animal.eat();
    }

    public static void main(String[] args) {
        func1(new Dog("旺财",2));
        func1(new Bird("小鹦鹉",4));
    }
}
